package cn.edu.sdjzu.xg.eagle.xg23_kcsj_01.controller;

import cn.edu.sdjzu.xg.eagle.xg23_kcsj_01.entity.Employee;
import cn.edu.sdjzu.xg.eagle.xg23_kcsj_01.entity.Paper;
import cn.edu.sdjzu.xg.eagle.xg23_kcsj_01.result.Result;
import cn.edu.sdjzu.xg.eagle.xg23_kcsj_01.service.EmployeeService;
import cn.edu.sdjzu.xg.eagle.xg23_kcsj_01.service.PaperService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


@RestController
public class PaperController {
    @Autowired
    private PaperService paperService;
    @GetMapping("/paper")
    public Result get(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestBody (required = false)Paper paper) {

        PageInfo<Paper> paperPageInfo = paperService.get(pageNum,pageSize,paper);
        System.out.println(paperPageInfo);
        return Result.success(paperPageInfo);
    }
    @PostMapping("paper")
    public Result save(@RequestBody Paper paper) {
        return Result.success(paperService.save(paper));
    }
    @PutMapping("paper")
    public Result update(@RequestBody Paper paper) {
        return Result.success(paperService.update(paper));
    }
    @DeleteMapping("paper/{id}")
    public Result delete(@PathVariable int id) {
        return Result.success(paperService.delete(id));
    }

}